package com.neutech.service.impl;

import com.neutech.mapper.PdrugMapper;
import com.neutech.service.PdrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PdrugServiceImpl implements PdrugService {
    @Autowired
    private PdrugMapper pdrugMapper;
    @Override
    public List<Map<String ,Object>> queryPdrugByName(String name){

        return pdrugMapper.queryPdrugByName(name);
    }

    @Override
    public List<Map<String, Object>> queryNotPdrugByState() {
        String ss="未发";
        return  pdrugMapper.queryPdrugByState(ss);
    }

    @Override
    public List<Map<String, Object>> queryAlPdrugByState() {
        String ss="已发";
        return  pdrugMapper.queryPdrugByState(ss);
    }


    @Override
    public List<Map<String, Object>> queryPdrugByIdnumber(Integer idnumber) {
        return pdrugMapper.queryPdrugByIdnumber(idnumber);
    }

    @Override
    public void updatePdrugByName(){
        Map<String,Object> map = pdrugMapper.queryPdrugByName("赵雷").get(0);
        map.put("drug","感冒胶囊");
        pdrugMapper.updatePdrugByName(map);
        System.out.println("更新成功");
    }

    @Override
    public void updatePdrugByIdnumber(Integer idnumber) {

        Map<String,Object> map =pdrugMapper.queryPdrugByIdnumber(idnumber).get(0);
        map.put("state","已发");
        pdrugMapper.updatePdrugByIdnumber(map);
    }

    @Override
    public void addPdrug(Map<String,Object> map){
//        for(Object key:map.keySet()){
//            Object value = map.get(key);
//            map.put((String) key,value);
//        }
        pdrugMapper.addPdrug(map);
    }

    @Override
    public void delpdrug(Integer num) {
        pdrugMapper.delpdrug(num);
    }
}
